<style src="./index.scss" lang="scss" scoped rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
    props: {},
    computed: {},
    data() {
        return {
            // 外部传入
            appWindow: null,
            // 外部传入
            apiConfig:null,
            // 窗口显示
            boxVisible: false,
            loading: true,
            type: 1,
            albumId: "",
            id: "",
            name: "",
            listAlbum: [],
        };
    },
    methods: {
        // 关闭窗口
        editBoxClose() {
            this.boxVisible = false;
        },
        // 取消
        editBoxCancel() {
            this.editBoxClose();
        },
      
        // 图片上传
        async submit() {
            if (this.name == "") {
                this.$vFN.Tools.messageError("素材名称不能为空");
                return;
            }

            let _data = await this.$vFN.Http.post(
                {
                    url: this.apiConfig.dataEdit.url,
                    domain: this.apiConfig.dataEdit.domain,
                    data: {
                        type: this.type,
                        albumId: this.albumId,
                        name: this.name,
                        id: this.id,
                    },
                },
                window
            );
            if (_data._ok) {
                this.editBoxClose();
                this.onSuccess();
                this.$vFN.Tools.messageSuccess("保存成功");
            }
        },

        async getAlbum() {
            console.error("apiConfig",this.apiConfig)
            let _data = await this.$vFN.Http.post(
                {
                    url: this.apiConfig.albumList.url,
                    domain: this.apiConfig.albumList.domain,
                    data: {
                        type: this.type,
                    },
                },
                window
            );
            if (_data._ok) {
                this.listAlbum = _data.data;
            }
        },

        async init() {
            this.boxVisible = true;
            this.loading = true;
            await this.getAlbum();
            this.loading = false;
        },

        // 成功回调
        onSuccess() {},
        // 取消回调
        onCancel() {},
        // 失败回调
        onError() {},
    },
    watch: {},
    mounted() {
        this.init();
    },
    beforeCreate() {},
};
</script>